﻿@model ManufacturerModel
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var manufacturerUrl = Url.RouteUrl("Manufacturer", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(manufacturerUrl);
    }
}
@using Autofac
@using Nop.Core;
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Customers
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Web;
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;
@{
    var isLogin = !EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsGuest();
}
<div class="page manufacturer-page">
    <div class="page-title">
        <h1>@Model.Name</h1>
    </div>
    <div class="clear">
    </div>
    <div class="page-body">
        @Html.Widget("manufacturerdetails_top")
        @*description*@
        @if (!String.IsNullOrWhiteSpace(Model.Description))
        {
            <div class="manufacturer-description">
                @Html.Raw(Model.Description)
            </div>
            <div class="clear">
            </div>
        }
        @Html.Widget("manufacturerdetails_before_featured_products")
        @*featured products*@
        @if (Model.FeaturedProducts.Count > 0)
        {
            <div class="product-grid featured-product-grid">
                <div class="title">
                    @T("Products.FeaturedProducts")
                </div>
                <div>
                    @(Html.DataList<ProductOverviewModel>(Model.FeaturedProducts, 2,
                    @<div class="item-box">
                        @Html.Partial("_ProductBox", item,new ViewDataDictionary()
                        {
                            { "IsLogin", isLogin }
                        })
                    </div>
                ))
                </div>
            </div>
            <div class="clear">
            </div>
        }
        @Html.Widget("manufacturerdetails_after_featured_products")
        @*view mode*@
        @if (Model.PagingFilteringContext.AllowProductViewModeChanging && Model.Products.Count > 0)
        {
            <div class="product-viewmode">
                <span>@T("Categories.ViewMode")</span>
                @Html.DropDownList("products-viewmode", Model.PagingFilteringContext.AvailableViewModes, new { onchange = "setLocation(this.value);" })
            </div>
        }
        @*sorting*@
        @if (Model.PagingFilteringContext.AllowProductSorting && Model.Products.Count > 0)
        {
            <div class="product-sorting">
                <span>@T("Categories.OrderBy")</span>
                @Html.DropDownList("products-orderby", Model.PagingFilteringContext.AvailableSortOptions, new { onchange = "setLocation(this.value);" })
            </div>
        }
    
        @*page size*@
        @if (Model.PagingFilteringContext.AllowCustomersToSelectPageSize && Model.Products.Count > 0)
        {
            <div class="product-page-size">
                <span>@T("Manufacturers.PageSize")</span> <span>@Html.DropDownList("products-pagesize", Model.PagingFilteringContext.PageSizeOptions, new { onchange = "setLocation(this.value);" })</span>
                <span>@T("Manufacturers.PageSize.PerPage")</span>
            </div>
        }
        <div class="clear">
        </div>
        @Html.Widget("manufacturerdetails_before_filters")
        @*filtering*@
        @if (Model.PagingFilteringContext.PriceRangeFilter.Enabled)
        {
            <div class="product-filters">
                <div class="filter-title">
                    <span>@T("Filtering.FilterResults")</span>
                </div>
                <div class="filter-item">
                    @Html.Partial("_FilterPriceBox", Model.PagingFilteringContext.PriceRangeFilter, new ViewDataDictionary())
                </div>
            </div>
            <div class="clear">
            </div>
        }
        @Html.Widget("manufacturerdetails_before_product_list")
        @*product list*@
        @if (Model.Products.Count > 0)
        {
            if (Model.PagingFilteringContext.ViewMode == "list")
            {
            @*list mode*@
            <div class="product-list">
                @foreach (var product in Model.Products)
                {
                    <div class="item-box">
                        @Html.Partial("_ProductBox", product,new ViewDataDictionary()
                        {
                            { "IsLogin", isLogin }
                        })
                    </div>
                }
            </div>
            }
            else
            {
            @*grid mode*@
            <div class="product-grid">
                @(Html.DataList<ProductOverviewModel>(Model.Products, 2,
                        @<div class="item-box">
                            @Html.Partial("_ProductBox", item,new ViewDataDictionary()
                            {
                                 { "IsLogin", isLogin }
                            })
                        </div>
                    ))
            </div>
            }
        }
        <div class="clear">
        </div>
        <div class="pager">
            @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
        </div>
        @Html.Widget("manufacturerdetails_bottom")
    </div>
</div>
